#include "stm32f4xx_hal.h"
#include "stdio.h"
#include "log.h"
#include "DevicesUart.h"
#include "DevicesQueue.h"
#include "DriverNetwork.h"


/* 数据发送 */
int8_t cNetWorkSendDatas(uint32_t uiChannel, void *pvBuff, int32_t iLength)
{
    int8_t cError = 0;

    if(pvBuff == NULL)
        return 1;

    if(iLength <= 0)
        return 2;

    if(uiChannel & NETWORK_CHANNEL_HARD_USB)
    {
        if(enumQueuePushDatas(&g_TypeQueueUSBSend, pvBuff, iLength) != queueNormal)
            cError |= 4;
    }

    if(uiChannel & NETWORK_CHANNEL_HARD_UART1)
    {
        vUartDMASendDatas(USART1, pvBuff, iLength);
    }

    if(uiChannel & NETWORK_CHANNEL_HARD_UART2)
    {
        vUartDMASendDatas(USART2, pvBuff, iLength);
    }

    if(uiChannel & NETWORK_CHANNEL_HARD_UART6)
    {
        vUartDMASendDatas(USART6, pvBuff, iLength);
    }

    return 0;
}
